package dimensional.one;

import java.util.Scanner;

public class ArrayExer02 {
    /*
     * 输入学生人数，并依次输入学生成绩，并将成绩保存在数组中。
     * 最后找出最高成绩，并判断所有人的成绩等级。
     */
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("请输入学生数量:");
        int num = scan.nextInt();
//        if (num < 0)
//            System.out.println("输入有误！请重新输入学生数量：");
        Student[] stu = new Student[num];
        int i = 0;
        float maxScore = 0;
        while (i < num) {
            System.out.print("请输入学生 " + ++i + " 的成绩：");
            float score = scan.nextFloat();
            stu[i - 1] = new Student(i, score);

            if (score > maxScore)
                maxScore = score;
        }

        System.out.println("最高成绩为：" + maxScore);
        for (Student student : stu) {
            float score = student.getScore();
            if (score >= maxScore - 10)
                student.setGrade('A');
            else if (score >= maxScore - 20) {
                student.setGrade('B');

            } else if (score >= maxScore - 30) {
                student.setGrade('C');
            } else {
                student.setGrade('D');
            }
            Student.printScore(student, student.getGrade());
            System.out.println(student);
        }

    }
}
